package com.crm.miaohe.controller.file;

import com.crm.miaohe.controller.file.response.FileInfo;
import com.crm.miaohe.service.FileUploadService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/api/erp/file")
public class FileUploadController {

    private FileUploadService fileUploadService;

    public FileUploadController(FileUploadService fileUploadService){
        this.fileUploadService = fileUploadService;
    }

    @PostMapping("upload")
    public ResponseEntity<FileInfo> uploadFile(MultipartFile file) throws IOException{
        return ResponseEntity.ok(fileUploadService.upload(file));
    }
}
